package com.gjw.planeWar;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.IOException;

/**
 * @author gjw19
 * @date 2019/5/1
 */
public class ResourceMgr {
    private static final ResourceMgr INSTANCE = new ResourceMgr();

    private ResourceMgr() {
    }

    public static ResourceMgr getInstance() {
        return INSTANCE;
    }

    // 飞机大战风格
    // 定义英雄飞机图片
    public static BufferedImage heroSketch;
    // 定义子弹图片
    public static BufferedImage bulletSketch;
    // 定义敌方飞机
    public static BufferedImage enemySketch;
    // 背景图片
    public static BufferedImage backgroundSketch;
    public static BufferedImage gameoverSketch;

    // 雷电风格
    // 定义英雄飞机图片
    public static BufferedImage heroRaiden;
    // 定义子弹图片
    public static BufferedImage bulletRaiden;
    // 定义敌方飞机
    public static BufferedImage enemyRaiden;
    // 背景图片
    public static BufferedImage backgroundRaiden;
    public static BufferedImage gameoverRaiden;

    // 静态代码块直接加载图片资源
    static {
        try {
            heroSketch = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/heroSketch.png"));
            bulletSketch = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/bulletSketch.gif "));
            enemySketch = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/enemySketch.png"));
            backgroundSketch = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/backgroundSketch.jpg"));
            gameoverSketch = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/gameoverSketch.png"));

            heroRaiden = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/heroRaiden.png"));
            bulletRaiden = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/bulletRaiden.png "));
            enemyRaiden = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/enemyRaiden.png"));
            backgroundRaiden = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/backgroundRaiden.gif"));
            gameoverRaiden = ImageIO.read(ResourceMgr.class.getClassLoader().getResourceAsStream("images/gameoverRaiden.jpg"));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
